/**
 * 
 */
package com.gi.profiler.db;

import com.gi.profiler.ProfilerApplication;
import com.j256.ormlite.android.apptools.OpenHelperManager;

/**
 * @author Ruba
 *
 */
public class DatabaseHelperManager {
    private static DatabaseHelper dbHelper = null;
    private static int helperCount = 0;


    public static DatabaseHelper getHelper() {
        if (dbHelper == null) {
            dbHelper = (DatabaseHelper)OpenHelperManager.getHelper(ProfilerApplication.getAppContext(), DatabaseHelper.class);
        }
        helperCount++;
        return dbHelper;
    }
    
    public static void releaseHelper() {
        if (--helperCount == 0 && dbHelper != null) {
            OpenHelperManager.releaseHelper();
            dbHelper = null;
        }
    }
}
